package jdbc;

public class Demo1 {
	public static void main(String[] args) {
		for (int i = -2; i < 128; i++) {
		byte b=(byte)i;
			System.out.println( "b= "+b+" | "+Integer.toString( ( b & 0xff ), 2)+" | "+Integer.toString( ( b & 0xff ), 16));
			System.out.println( "b= "+b+" | "+Integer.toString(  (int)b  , 2)+" | "+Integer.toString(  b  , 16));
			String s=Integer.toString( ( b & 0xff ), 2);
			s=addPrefix(s, 8);
			System.out.println(s);
		}
	}
	
	private static String addPrefix(String string,int standardLength){
		if(string==null){
			return null;
		}
		int i=standardLength-string.length();
		if(i<=0){
			return string;
		}
		StringBuffer stringBuffer=new StringBuffer();
		for(int j=0;j<i;j++){
			stringBuffer.append("0");
		}
		return string+stringBuffer.toString();
	}
}
